home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 5 / Skunkware 5.iso / src / X11 / Fresco / build / Unix / config / util / mergelib.cpp < prev    next >
Encoding:
Text File  |  1995-07-12  |  2.8 KB  |  104 lines

  1. XCOMM!/bin/sh
  2. XCOMM
  3. XCOMM $XConsortium: mergelib.cpp,v 1.4 94/04/17 20:10:43 rws Exp $
  4. XCOMM 
  5. XCOMM Copyright (c) 1989  X Consortium
  6. XCOMM 
  7. XCOMM Permission is hereby granted, free of charge, to any person obtaining a copy
  8. XCOMM of this software and associated documentation files (the "Software"), to deal
  9. XCOMM in the Software without restriction, including without limitation the rights
  10. XCOMM to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  11. XCOMM copies of the Software, and to permit persons to whom the Software is
  12. XCOMM furnished to do so, subject to the following conditions:
  13. XCOMM 
  14. XCOMM The above copyright notice and this permission notice shall be included in
  15. XCOMM all copies or substantial portions of the Software.
  16. XCOMM 
  17. XCOMM THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  18. XCOMM IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  19. XCOMM FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
  20. XCOMM X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
  21. XCOMM AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  22. XCOMM CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  23. XCOMM 
  24. XCOMM Except as contained in this notice, the name of the X Consortium shall not be
  25. XCOMM used in advertising or otherwise to promote the sale, use or other dealings
  26. XCOMM in this Software without prior written authorization from the X Consortium.
  27. XCOMM 
  28. XCOMM Author:  Jim Fulton, MIT X Consortium
  29. XCOMM 
  30. XCOMM mergelib - merge one library into another; this is commonly used by X
  31. XCOMM     to add the extension library into the base Xlib.
  32. XCOMM
  33.  
  34. usage="usage:  $0  to-library from-library [object-filename-prefix]"
  35. objprefix=_
  36.  
  37. case $# in
  38.     2) ;;
  39.     3) objprefix=$3 ;;
  40.     *) echo "$usage" 1>&2; exit 1 ;;
  41. esac
  42.  
  43. tolib=$1
  44. fromlib=$2
  45.  
  46. if [ ! -f $fromlib ]; then
  47.     echo "$0:  no such from-library $fromlib" 1>&2
  48.     exit 1
  49. fi
  50.  
  51. if [ ! -f $tolib ]; then
  52.     echo "$0:  no such to-library $tolib" 1>&2
  53.     exit 1
  54. fi
  55.  
  56.  
  57. XCOMM
  58. XCOMM Create a temp directory, and figure out how to reference the 
  59. XCOMM object files from it (i.e. relative vs. absolute path names).
  60. XCOMM
  61.  
  62. tmpdir=tmp.$$
  63. origdir=..
  64.  
  65. mkdir $tmpdir
  66.  
  67. if [ ! -d $tmpdir ]; then
  68.     echo "$0:  unable to create temporary directory $tmpdir" 1>&2
  69.     exit 1
  70. fi
  71.  
  72. case "$fromlib" in
  73.     /?*) upfrom= ;;
  74.     *)  upfrom=../ ;;
  75. esac
  76.  
  77. case "$tolib" in
  78.     /?*) upto= ;;
  79.     *)  upto=../ ;;
  80. esac
  81.  
  82.  
  83. XCOMM
  84. XCOMM In the temp directory, extract all of the object files and prefix
  85. XCOMM them with some symbol to avoid name clashes with the base library.
  86. XCOMM
  87. cd $tmpdir
  88. ar x ${upfrom}$fromlib
  89. for i in *.o; do
  90.     mv $i ${objprefix}$i
  91. done
  92.  
  93.  
  94. XCOMM
  95. XCOMM Merge in the object modules, ranlib (if appropriate) and cleanup
  96. XCOMM
  97. ARCMD ${upto}$tolib *.o
  98. RANLIB ${upto}$tolib
  99. cd $origdir
  100. rm -rf $tmpdir
  101.  
  102.  
  103.  
  104.